#if __has_include(<SEGMasonry/SEGMasonry.h>)
#import <SEGMasonry/SEGMasonry.h>
#else
#import "SEGMasonry.h"
#endif

#import "SEGRootViewController.h"
#import "SEGRootView.h"
#import "SEGRootViewModel.h"

@interface SEGRootViewController ()
@property (nonatomic, strong) SEGRootView* rootView;
@property (nonatomic, strong) SEGRootViewModel* viewModel;
@end

@implementation SEGRootViewController

#pragma mark - life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = (self.title && self.title.length > 0) ? self.title : @"SEGRootViewController";
    self.automaticallyAdjustsScrollViewInsets = self.automaticallyAdjustsScrollViewInsets ? self.automaticallyAdjustsScrollViewInsets : NO;

    [self segInitViews];
    [self updateViewConstraints];
    [self bindViewModel];
}

- (void)dealloc {
    NSLog(@"%s",__FUNCTION__);
}

#pragma mark - Init Views
-(void)segInitViews{
    self.view.backgroundColor = [UIColor whiteColor];

    [self.view addSubview:self.rootView];
}

#pragma mark - Layout
- (void)updateViewConstraints {
    [self.rootView seg_makeConstraints:^(SEGConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.top.equalTo(self.view);
        make.right.equalTo(self.view);
        make.bottom.equalTo(self.view);
    }];
    
    [super updateViewConstraints];
}

//#pragma mark - public methods
//#pragma mark - private methods
//#pragma mark - [系统]Delegate
//#pragma mark - [自定义]Delegate
//#pragma mark - Event Response

#pragma mark - RAC Data Binding
- (void)bindViewModel {}

#pragma mark - getter
- (SEGRootView *)rootView {
    if (!_rootView) {
        _rootView = [[SEGRootView alloc] initWithViewModel:self.viewModel];
    }
    return _rootView;
}

-(SEGRootViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel = [[SEGRootViewModel alloc]init];
    }
    return _viewModel;
}
#pragma mark setter
@end
